//
// Created by chizuru on 2025/9/16.
//

#pragma once
#include "ProtocolResult.h"
#include "CommandId.h"
#include <span>
#include <string>

struct IProtocolCodec {
    virtual ~IProtocolCodec() = default;

    using CodecArg = ProtocolResult::CodecArg;
    using CodecArgs = std::vector<CodecArg>;

    virtual std::vector<uint8_t> buildWriteFrame(const CommandId&, const CodecArgs& args) const = 0;
    virtual std::vector<uint8_t> buildReadFrame(const CommandId&, const CodecArgs& args = {}) const = 0;

    virtual ProtocolResult parseWriteResponse(std::span<const uint8_t> resp, const CommandId& commandId = {}, const CodecArgs& args = {}) const = 0;
    virtual ProtocolResult parseReadResponse(std::span<const uint8_t> resp, const CommandId& commandId = {}, const CodecArgs& args = {}) const = 0;
};

